home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / text / hyper / hsc_source.lha / hsc / source / hsclib / posteval.c < prev    next >
C/C++ Source or Header  |  1996-09-06  |  3KB  |  115 lines

  1. /*
  2.  * hsclib/posteval.c
  3.  *
  4.  * functions to postprocess attributes
  5.  * (remember IDs, references, etc)
  6.  *
  7.  * Copyright (C) 1995,96  Thomas Aglassinger
  8.  *
  9.  * This program is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2 of the License, or
  12.  * (at your option) any later version.
  13.  *
  14.  * This program is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  * GNU General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License
  20.  * along with this program; if not, write to the Free Software
  21.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  *
  23.  * updated:  6-Sep-1995
  24.  * created:  7-Jul-1995
  25.  */
  26.  
  27. #define NOEXTERN_HSCLIB_EVAL_H
  28.  
  29. #include <ctype.h>
  30.  
  31. #include "hsclib/inc_base.h"
  32.  
  33. #include "hscprj/document.h"
  34. #include "hsclib/idref.h"
  35. #include "hsclib/uri.h"
  36.  
  37. /*
  38.  * postprocess_attributes
  39.  *
  40.  * This functions scans a tag's list of attributes for an URI-attributes
  41.  * refering to an external URI. If it succeeds, and the hsc-process
  42.  * has it's hp->strip_ext flag enabled, the function exits.
  43.  *
  44.  * Otherwise, it scans the attributes for new IDs and references
  45.  * and updates the document-data if neccessary (but only for start-tags)
  46.  *
  47.  * params:
  48.  *   hp ....... hsc-process
  49.  *   tag ... tag whichs attribute list chould be examined
  50.  *   open_tag .. for end-tags, the document-data should not be
  51.  *               updated again
  52.  * result:
  53.  *   TRUE, if tag should NOT be stripped
  54.  */
  55. BOOL postprocess_tagattr(HSCPRC * hp, HSCTAG * tag, BOOL open_tag)
  56. {
  57.     BOOL dontstrip = TRUE;
  58.  
  59.     if (tag->attr)
  60.     {
  61.  
  62.         /*
  63.          * find out, if list should be refused
  64.          */
  65.         if (hp->strip_ext
  66.             && tag->uri_stripext
  67.             && get_vartext(tag->uri_stripext)
  68.             && (uri_kind(get_vartext(tag->uri_stripext)) == URI_ext)
  69.             )
  70.         {
  71.             D(fprintf(stderr, DHL "strip external\n"));
  72.             dontstrip = FALSE;
  73.         }
  74.         else if (open_tag)
  75.         {
  76.             /*
  77.              * search for new IDs and references
  78.              */
  79.             DLNODE *nd = dll_first(tag->attr);
  80.             while (nd)
  81.             {
  82.                 HSCATTR *attrib = (HSCATTR *) dln_data(nd);
  83.                 STRPTR value = get_vartext(attrib);
  84.  
  85.                 if (value)
  86.                 {
  87.                     if (attrib->vartype == VT_URI)
  88.                     {
  89.                         /* new reference */
  90.                         INFILEPOS *fpos = new_infilepos(hp->inpf);
  91.                         CALLER *newcaller = fpos2caller(fpos);
  92.                         HSCREF *newref =
  93.                         app_reference(hp->project->document, value);
  94.  
  95.                         newref->caller = newcaller;
  96.  
  97.                         del_infilepos(fpos);
  98.                         D(fprintf(stderr, DHL "new REFERENCE: `%s'\n", value));
  99.  
  100.                     }
  101.                     else if (attrib->vartype == VT_ID)
  102.                     {
  103.                         /* new id defined */
  104.                         D(fprintf(stderr, DHL "new ID: `%s'\n", value));
  105.                         add_local_iddef(hp, value);
  106.                     }
  107.                 }
  108.                 nd = dln_next(nd);
  109.             }
  110.         }
  111.     }
  112.     return (dontstrip);
  113. }
  114.  
  115.